<extend name="Base/common"/>
<block name="Content">
    <div class="am-cf am-padding-top">
        <div class="am-fl am-cf">
            <i class="am-icon-cog"></i>
            <strong class="am-text-primary am-text-lg">配置设置</strong>
        </div>
        <hr data-am-widget="divider" class="am-divider am-divider-default" />
    </div>
    
        <div class="am-tabs am-margin" data-am-tabs-noswipe="1" data-am-tabs>
            <ul class="am-tabs-nav am-nav am-nav-tabs">
            	<notempty name="list">
            		<volist name="list" id="tag">
	                <li <if condition="key eq 1"> class="am-active"</if> >
	                    <a href="#tab{$key}">{$tag.tab_name}配置</a>
	                </li>
	                </volist>
	            </notempty>
                <li>
                    <a href="#tab0">增加配置</a>
                </li>
            </ul>
            
            <div class="am-tabs-bd">
            	
            	<notempty name="list">
            		<volist name="list" id="tag" key="k">
		                <div <if condition="k eq 1">class="am-tab-panel am-in am-active" <else /> class="am-tab-panel"</if> id="tab{$k}">
		                	<form  class="am-form am-form-{$k}" action="{:U('Config/edit')}">
		                	<volist name="tag['config']" id="config">
			                    <div class="am-g am-margin-top">
			                    	
			                        <div class="am-u-sm-2 am-text-right">
			                            {$config.config_info}
			                        </div>
			                        <div class="am-u-sm-4">
			                                
			                                <switch name="config.config_type">
					                            <case value="number">
					                                <input type="number" class="am-form-field am-input-sm" name="{$config.config_name}" value="{$config.config_value}">
					                            </case>
					                            <case value="string">
					                                <input type="text" class="am-form-field am-input-sm" name="{$config.config_name}" value="{$config.config_value}">
					                            </case>
					                            <case value="textarea">
				                                	<textarea class="am-form-field am-input-sm" rows="2" name="{$config.config_name}">{$config.config_value}</textarea>
					                            </case>
					                            <case value="richtext">
				                                	<textarea class="am-input-sm am-input-sm-rich" rows="2" 
				                                		name="{$config.config_name}" id="{$config.config_name}">{$config.config_value}</textarea>
					                            </case>
					                            <case value="bool">
					                                <label class="am-radio-inline">
					                                    <input type="radio" name="{$config.config_name}" value="0" data-am-ucheck 
					                                    	<eq name="config.config_value" value="0">checked</eq> />是
					                                </label>
					                                <label class="am-radio-inline">
					                                    <input type="radio" name="{$config.config_name}" value="1" data-am-ucheck
					                                    	<eq name="config.config_value" value="1">checked</eq> >否
					                                </label>
					                            </case>
					                            <case value="array">
				                                	<textarea class="am-form-field am-input-sm" rows="2" name="{$config.config_name}">{$config.config_value}</textarea>
					                            </case>
					                            <case value="extra">
				                                	<select data-am-selected="{ btnSize: 'sm', btnStyle: 'secondary'}" name="{$config.config_name}">
                                   
				            							<volist name=":parse_config_attr($config['config_extra'])" id="vo">
				            								<option value="{$key}" <eq name="config.config_value" value="$key">selected</eq>>{$vo}</option>
				            							</volist>
					            						
					                                </select>
					                            </case>
				                            </switch>
			                                
			                        </div>
			                        <div class="am-u-sm-3">
			                            <span class="am-text-secondary">（{$config.remark}）</span>
			                        </div>
									<div  class="am-u-sm-3">
			                    		{$config.config_name}
			                    	</div>
			                    </div>
		                    </volist>
		                    <notempty name="tag['config']">
		                    <div class="am-margin">
			                    <button type="submit" class="am-btn am-btn-success am-btn-xs ajax-post" target-form="am-form-{$k}">
			                        提交保存
			                    </button>
			                </div>
			                </notempty>
		                    </form>
		                </div>
		                
                	</volist>
	            </notempty>
                
                <div class="am-tab-panel" id="tab0">
                    <form class="am-form am-form-0" action="{:U('Config/add')}">
                        <div class="am-g am-margin-top-sm">
                            <div class="am-u-sm-4 am-u-md-2 am-text-right">
                                配置项英文标识
                            </div>
                            <div class="am-u-sm-8 am-u-md-4 am-u-end">
                                <input type="text" class="am-input-sm" name="config_name" required/>
                            </div>
                        </div>
                        <div class="am-g am-margin-top-sm">
                            <div class="am-u-sm-4 am-u-md-2 am-text-right">
                                配置项中文名称
                            </div>
                            <div class="am-u-sm-8 am-u-md-4 am-u-end">
                                <input type="text" class="am-input-sm" name="config_info" required/>
                            </div>
                        </div>
                        <div class="am-g am-margin-top">
                            <div class="am-u-sm-4 am-u-md-2 am-text-right">
                                所属标签
                            </div>
                            <div class="am-u-sm-8 am-u-md-4">
                                <select data-am-selected="{ btnSize: 'sm', btnStyle: 'secondary'}" name="config_group">
                                    
                                    <notempty name="list">
            							<volist name="list" id="tag">
            								<option value="{$key}">{$tag['tab_name']}</option>
            							</volist>
            						</notempty>
            						
                                </select>
                            </div>
                            <div class="am-hide-sm-only am-u-md-6">
                            </div>
                        </div>
                        <div class="am-g am-margin-top">
                            <div class="am-u-sm-4 am-u-md-2 am-text-right">
                                数据类型
                            </div>
                            <div class="am-u-sm-8 am-u-md-4">
                                <select data-am-selected="{ btnSize: 'sm', btnStyle: 'secondary'}" name="config_type">
                                    <option value="string">单选文本</option>
                                    <option value="textarea">多行文本</option>
                                    <option value="richtext">富文本</option>
                                    <option value="number">数字</option>
                                    <option value="bool">布尔（Y/N)</option>
                                    <option value="array">数组</option>
                                    <option value="extra">枚举</option>
                                </select>
                            </div>
                            <div class="am-hide-sm-only am-u-md-6">
                            </div>
                        </div>
                        <div class="am-g am-margin-top-sm">
                            <div class="am-u-sm-4 am-u-md-2 am-text-right">
                                配置值:
                            </div>
                            <div class="am-u-sm-8 am-u-md-4 am-u-end">
                                <textarea class="am-form-field am-input-sm" rows="2" name="config_value" required></textarea>
                            </div>
                            <div class="am-u-md-6">
                            	<span class="am-text-secondary">（如果为数组类型，每行表示数组一个元素，并标识数组索引）</span>
                            </div>
                        </div>
                        <div class="am-g am-margin-top-sm">
                            <div class="am-u-sm-4 am-u-md-2 am-text-right">
                                配置值:
                            </div>
                            <div class="am-u-sm-8 am-u-md-4 am-u-end">
                                <textarea class="am-form-field am-input-sm" rows="2" name="config_extra"></textarea>
                            </div>
                            <div class="am-u-md-6">
                            	<span class="am-text-secondary">（如果为枚举型，需配置该项）</span>
                            </div>
                        </div>
                        <div class="am-g am-margin-top-sm">
                            <div class="am-u-sm-4 am-u-md-2 am-text-right">
                                配置说明:
                            </div>
                            <div class="am-u-sm-8 am-u-md-4 am-u-end">
                                <input type="text" class="am-input-sm" name="remark"/>
                            </div>
                        </div>
                        <div class="am-margin">
                            <button type="submit" class="am-btn am-btn-success am-btn-xs ajax-post" target-form="am-form-0">
                                提交保存
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        </block>

<block name="script">
    <script src="__PUBLIC__/Common/js/ueditor/ueditor.config.js" type="text/javascript"></script>
    <script src="__PUBLIC__/Common/js/ueditor/ueditor.all.min.js" type="text/javascript"></script>
    <script src="__PUBLIC__/Common/js/ueditor/lang/zh-cn/zh-cn.js" type="text/javascript"></script>
    
    <script type="text/javascript">

    	(function($){
    		
    		var richText = $(".am-input-sm-rich");
    		richText.each(function(i){
    			
    			UE.getEditor($(this).attr('id'),{
    		        toolbars:[[
    		        "fullscreen", '|', 'undo', 'redo', "|","bold", "italic", "underline", 'fontborder', 
    		        'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch',
    		        'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 
    		        'insertunorderedlist', 'selectall', 'cleardoc', "|", 
    		        'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
    		        'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
    		        'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', 'insertimage']],
    		        wordCount:false,enableAutoSave:false,elementPathEnabled:false
    			});
    			
    		});
    	})(jQuery);
    </script>
</block>

        